package com.bootcamp.mall.dao;

import com.bootcamp.mall.model.Goods;
import com.bootcamp.mall.model.GoodsType;
import com.bootcamp.mall.model.Order;
import com.bootcamp.mall.model.Spec;
import com.bootcamp.mall.model.bo.goods.MsgBO;
import com.bootcamp.mall.model.vo.goods.CommentOfGetVO;
import com.bootcamp.mall.model.vo.goods.GoodsMsgVO;
import com.bootcamp.mall.model.vo.goods.MsgVO;
import com.bootcamp.mall.model.vo.goods.GoodsVO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * @program: mall
 * @description: 对goods进行增删查改
 * @author: Keyu Li
 * @create: 2021-11-10 14:54
 **/

public interface GoodsDao {
    List<GoodsType> selectAllTypes();

    List<GoodsVO> selectGoods(Goods goods);

    Integer insertTypes(GoodsType type);

    Integer deleteTypeById(@Param("typeId") Integer typeId);

    Integer updateGoodsTypeId(@Param("newTypeId") Integer newTypeId, @Param("typeId") Integer typeId);

    /**
     * 插入goods商品，并将自增的主键值保存到goods对象中
     *
     * @param goods:
     * @return java.lang.Integer 返回1是正常
     * @date 11/10/2021 20:24
     */
    Integer insertGoods(Goods goods);

    Integer insertSpec(List<Spec> spec);

    GoodsVO selectGoodsById(@Param("id") Integer id);

    List<Spec> selectSpecListByGoodsId(@Param("goodsId") Integer goodsId);

    Integer deleteGoodsById(Integer id);

    Integer deleteSpecByGoodsId(Integer id);

    Integer updateGoodsById(Goods goods);

    /**
     * 执行多条update语句，但是返回结果是个啥？
     *
     * @param specs:
     * @return java.lang.Integer
     * @date 11/11/2021 15:52
     */
    Integer updateSpecById(List<Spec> specs);


    List<Spec> selectSpecIDAndNameAndPriceByGoodsId(Integer goodsId);

    /**
     * 查询spec表获取unitprice
     *
     * @param id:
     * @return java.math.BigDecimal
     * @date 11/11/2021 21:25
     */
    BigDecimal selectSpecUnitPriceById(Integer id);

    List<MsgVO> selectMsgByState(Integer state);

    Integer updateMsgByAddReply(MsgBO msgBO);

    List<GoodsMsgVO> selectMsgAndAskerByGoodsId(@Param("goodsId") Integer goodsId);

    /**
     * 插入新留言到留言表，需要联合user表获得userid
     *
     * @param msgBO:
     * @return java.lang.Integer
     * @date 11/12/2021 21:24
     */
    Integer insertMsg(MsgBO msgBO);

    Order selectSpecAndGoodsById(@Param("specId") Integer specId);

    String selectSpecNameById(Integer specId);

    List<CommentOfGetVO> selectCommentByGoodsId(@Param("goodsId") Integer goodsId);

    Integer deleteSpecByGoodsIdAndName(Spec deleteSpecBO);

}
